import paho.mqtt.client as mqtt
import time

homename = "m14.cloudmqtt.com"
port = 13536
user = "xxxx"
user_password = "xxxx"


def on_message(client, userdata, message):
    print("message {} at {}".format(str(message.payload.decode("utf-8")),  message.topic))


client = mqtt.Client("paho pub")
client.on_message = on_message
client.username_pw_set(user, user_password)
client.connect(homename, port)
# client.loop_start()
client.publish("/hello","from paho")
# time.sleep(1)
# client.loop_stop()
